	
	<style>
	/* multiselect styles */
	.multiselect {
		width: 271px;
		height: 200px;
	}
	
	/* patient_file */
	#patient_file div {float:left; padding:5px;}
	</style>

	<link type="text/css" href="<?php echo base_url()?>css/ui.multiselect.css" rel="stylesheet" />
	<script type="text/javascript" src="<?php echo base_url()?>js/ui.multiselect.js"></script>
	<script type="text/javascript">
	$(function() {
		$('#dialog, #templates').dialog({
			autoOpen: false,
			show: 'explode',
			hide: 'explode',
			modal: true
		});		
	});
		function openLastVist()
		{
			$('#dialog').dialog('open');
			return false;
		}

                function open_templates()
                {
                    $('#templates').dialog('open');
                    //get all template list
                    return false;
                }

		$(function(){
			$(".multiselect").multiselect();
			$(".selected").css("width","150px");
			$(".available").css("width","119px");
		});
		
		
	$(function() {
		$('#submitbtn').hide();
		$("#patient_id2").autocomplete({
			source: "<?php echo site_url()?>?c=search&m=patient",
			select: function(event, ui) {
				$("#searched_id").val(ui.item.id);
				show_details(ui.item.id,ui.item.code);
			}
		});

         <? if(!empty($patient_id) && !empty($code)){ ?> show_details('<?php echo $patient_id?>','<?php echo $code?>'); <? } ?>
          function show_details(id,code){
              $('#attachment').html('<br><br><img src=<?php echo base_url ()?>images/loading.gif>');
              $('#lastvisit').html('<br><br><img src=<?php echo base_url ()?>images/loading.gif>');

               $('#submitbtn').show();

/////////////////////////////get_attachments

$.post("<?php echo site_url()?>/patient/get_attachments/"+code+'/1',
		   function(data){
              html='	<h2>Attachment</h2><ul>';
           for(var i in data)
               html+='<li><a TARGET="_blank" href="<?php echo base_url ()?>AttachedData/'+code+'/'+data[i]+'">'+ data[i] +'</li>'

           html+='</ul>'
               
               $('#attachment').html(html);
	   
},'json');
 


////////////////////////////////get_last_visit

$.post("<?php echo site_url()?>/patient/get_last_visit/"+id,
		   function(data){
	   if(typeof data.preview_date!='undefined'){ 
	   var html='<h2>Last Visit</h2><ul><li> Was on: <b>'+data.preview_date+'</b> <a href="#" onClick="openLastVist()">Show </a></li></ul>'
	          $('#lastvisit').html(html);
	   $('#dialog').attr('title',data.preview_date)
html='<p class="p1">notes'+data.note+'</p>'+'<p class="p1">'+data.preview_date+'</p>'
if(typeof data.examination!='undefined'){
	html+='<ul>Examination</ul>'
	for(var i in data.examination)
		html+='<li>'+data.examination[i]+'</li>'
}
		if(typeof data.checkup!='undefined'){
			html+='<ul>Checkup</ul>'
			for(var i in data.checkup)
				html+='<li>'+data.checkup[i]+'</li>'
		}
	$('#dialog').html(html);
	   }
                      else{
                      var html='<h2>Last Visit</h2>';
                      $('#lastvisit').html(html);
                      }
		   },'json');
 



$("#patient_file").show('slow');
//$("#content").slideDown();

          }
           
		
	});

        function write_the_template(str)
	{
		$.post("<?php echo site_url()?>/preview/ajax_get_template_content/"+str,
		   function(data){
                        //$('iframe').contents().find('html').html(data);
                        $('iframe').get(0).contentWindow.document.body.innerHTML = data.template;
                        $('#templates').dialog('close');
		   },'json');
	}
	</script>



	<div id="templates" title="<?php echo lang('menuitem_template')?>">
		<?php
		
		
                if($count_templates > 0){

                echo '<select onChange="write_the_template(this.value)" >';
                echo "<option>".  lang('menuitem_select') ."</option>";
                foreach($templates as $key)
                {
                    echo '<option id="'.$key['id'].'" value="'.$key['id'].'" >'.$key['name'].'</option>';
                }
                 echo "</select>"   ;
                }
                else {
                    echo lang('general_no_data_found');
                }
                ?>
	</div>


	<div id="dialog" title="12-09-2009">
	</div>
        <?php echo lang('menuitem_patient')?> : <input type="text" id="patient_id2" value="<?php if(!empty($patient_name)) echo $patient_name;?>">
        <form method="post" action="<?php echo site_url()?>/preview/save_new_preview" >
	<input type="hidden" id="searched_id" name="patient_id" value="<?php if(!empty($patient_id)) echo $patient_id;?>">
	
	<!-- doctor to patient -->
	<div id="patient_file" style="display:none">
		<!--sensitivity-->
		<div id="sensitivity">
			<h2><?php echo lang('menuitem_medical_history')?></h2>
				<ul>
					<li> Anti-Histamine </li>
					<li> Sensitivity 1 </li>
					<li> Sensitivity 2 </li>
					<li> Sensitivity 3 </li>
				</ul>
		</div>
		<!--END sensitivity-->
		
		<!--attachment-->
		<div id="attachment">
		</div>
		<!--END attachment-->
		
		<!-- lastvisit-->
		<div id="lastvisit">
		</div>
		<!--END lastvisit-->

	</div>
        <div style="clear:both;"></div>
        <hr>
        
        <span class="btn-larg" class="btn" onclick="$('#note').show('slow')"><?php echo lang('menuitem_add').' '.lang('form_label_note')?></span>
        

        <hr>
        <div id="note" style="display:none">


            <span id="temp-selector" class="btn" onclick="open_templates()"><?php echo lang('menuitem_template')?></span>
            <textarea name="notes" id="wysiwyg" rows="15" cols="70" class="tinymce"></textarea>
           
        </div>

	
	<div id="content" >

<table width=100% cellpadding=1 cellspacing=1>
	<tr>
		<th> List </th>
		<th> Checkup </th>
		<th>  </th>
	</tr>
	<tr>
		<td>
		       <select id="examination_ids" class="multiselect" MULTIPLE multiple="multiple" name="examination_ids[]">
				<?php
				foreach($list_preview as $row){
					echo "<option value='".$row['id']."'>".$row['name']."</option>";
				}
				?>
			  </select>
      </td>
     
     <td>
		<select id="checkup_ids" class="multiselect" MULTIPLE multiple="multiple" name="checkup_ids[]">
				<?php
				foreach($list_price as $row){
					echo "<option value='".$row['id']."'>".$row['test_name']."</option>";
				}
				?>
			  </select>
     </td>
     
      <td>

      </td>
	</tr>
</table>
    
   
            <input id="submitbtn" type="submit" value="Submit Form" class="btn"   />

</form>
 </div>

<!-- TinyMCE -->
<script type="text/javascript" src="<?php echo base_url()?>js/tiny_mce/jquery.tinymce.js"></script>
<script type="text/javascript">


	$().ready(function() {
		
		$('textarea.tinymce').tinymce({
			// Location of TinyMCE script
			script_url : '<?php echo base_url()?>js/tiny_mce/tiny_mce.js',

			// General options
			theme : "advanced",
			plugins : "pagebreak,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

			// Theme options
			theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
			//theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
			//theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,

			// Example content CSS (should be your site CSS)
			//content_css : "css/content.css",

			// Drop lists for link/image/media/template dialogs
			template_external_list_url : "lists/template_list.js",
			external_link_list_url : "lists/link_list.js",
			external_image_list_url : "lists/image_list.js",
			media_external_list_url : "lists/media_list.js",

			// Replace values for the template plugin
			template_replace_values : {
				username : "Some User",
				staffid : "991234"
			}

		});
	});




</script>
<!-- /TinyMCE -->